package com.hc.model.code01.test2.after;

public class RectangleDemo {

    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle();
        rectangle.setLength(20);
        rectangle.setWidth(10);
        resize(rectangle);
        printWidthLength(rectangle);
        System.out.println("==================");
        Square square = new Square();
        square.setLength(20);
        resize(square);
        printWidthLength(square);
    }

    // 扩充宽度
    public static void resize(Rectangle rectangle) {
        while (rectangle.getWidth() <= rectangle.getLength()) {
            rectangle.setWidth(rectangle.getWidth() + 1);
        }
    }

    // 打印结果
    public static void printWidthLength(Rectangle rectangle) {
        System.out.println(rectangle.getLength());
        System.out.println(rectangle.getWidth());
    }
}
